import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '../views/HomeView.vue';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: HomeView,
      meta:{
        title: '首页'
      }
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (About.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import('../views/AboutView.vue'),
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/Dengluyuzhuce/LoginView.vue'),
      meta:{
        title: '登录页'
      }
    },
    {
      path: '/reg',
      name: 'reg',
      component: () => import('../views/Dengluyuzhuce/RegView.vue'),
      meta:{
        title: '注册页'
      }
    },
    {
      path: '/xiangqing',
      name: 'xiangqing',
      component: () => import('../views/Shangpin/XiangqingView.vue'),
      meta:{
        title: '详情页'
      }
    },
    {
      path: '/sousuo',
      name: 'sousuo',
      component: () => import('../views/Sousuo/SousuoView.vue'),
      meta:{
        title: '搜索页'
      }
    },
    {
      path: '/gouwuche',
      name: 'gouwuche',
      component: () => import('../views/Shangpin/GouwucheView.vue'),
      meta:{
        title: '购物车页'
      }
    },
  ],
});
router.afterEach(function(to){
  document.title = to.meta.title;
})

export default router;
